/* eslint-disable jsdoc/no-restricted-syntax */
"use strict";

const stream = require("node:stream");
const connect = require("connect");

const rawData = '{"name": "John"}';
const dataB64 = Buffer.from(rawData, "base64");
const dataSource = new Uint8Array(dataB64);
class MyDuplex extends stream.Duplex {
  constructor() {
    super();
  }

  /**
   * @param {*} chunk
   * @param {BufferEncoding} encoding
   * @param { (error?: Error | null) => void} callback
   */
  _write(chunk, encoding, callback) {
    console.log("_write", chunk.toString());
    callback();
  }

  /**
   * @param {number} size
   */
  _read(size) {
    console.log("_read");
  }
}

class ReadableDong extends stream.Readable {
  _read() {
    this.push("114");
    this.push("514");
    this.push("616");
    this.push(null);
  }
}

const readableStream = new ReadableDong();

readableStream.on("data", (data) => {
  console.log(data.toString());
});

readableStream.on("end", () => {
  console.log("done");
});
